/**
 * 
 */
package com.changil.nowonchangilchurch.common;


import android.os.AsyncTask;

/**
 * @author zeropol2
 *
 */
public class SleepTask {
	public interface SleepTaskListener {
		public void onSleepTaskCompleted();
	}
	private SleepTaskListener mSleepTaskListener;
	
	private SleepTask(){}
	
	public static SleepTask newInstance() {
		return new SleepTask();
	}
	
	public void setSleepTaskListener(SleepTaskListener l) {
		mSleepTaskListener = l;
	}
	
	public void execute(int sleepMillSeconds) {
		new RefreshCompleteTask().execute(sleepMillSeconds);
	}
	
	class RefreshCompleteTask extends AsyncTask<Integer, Void, Void> {

        @Override
        protected Void doInBackground(Integer... params) {
        	//로딩바가 너무 빨리 없어지는게 어색해서 일부로 시간을 좀 둔다음에 없애도록 함
            try {
                Thread.sleep(params[0]);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);
			mSleepTaskListener.onSleepTaskCompleted();
        }
    }
}
